<?php
ini_set("error_reporting","E_ALL & ~E_NOTICE");
header('Content-type: application/json');
$jsoncallback = htmlspecialchars($_REQUEST ['jsoncallback']);//获取回调函数名

$del_id=$_GET["del_id"];$del_id = preg_replace('# #','',$del_id);
$token=$_GET["token"];
if (!$del_id) {
    $data['status']="NO";
    $data['message']="ID 验证失败，请您重新登录后重试！";
    echo $jsoncallback . "(" . json_encode($data, JSON_UNESCAPED_UNICODE) . ")";
    die();
}

if ($token != "Jmwpower") {
    $data['status']="NO";
    $data['message']="数据验证失败[Token 口令不正确]，请您检查后重试！";
    echo $jsoncallback . "(" . json_encode($data, JSON_UNESCAPED_UNICODE) . ")";
    die();
}

$servername = "localhost";
$username = "username";//需要修改为你的 数据
$password = "password";
$dbname = "dbname";

$con = new mysqli($servername, $username, $password, $dbname);
if (mysqli_connect_errno()){// 检测连接-失败回传钉钉信息
    mysqli_close($con);//关闭数据库
    $data['status']="NO";
    $data['message']="链接数据库失败，请稍候刷新重试！";
    echo $jsoncallback . "(" . json_encode($data, JSON_UNESCAPED_UNICODE) . ")";
}else{//读取记录数据
    if(mysqli_query($con,"DELETE FROM `url` WHERE id='$del_id'")==true){//更新数据成功，如失败，钉钉回传数据
        $data['status']="YES";
        $data['message']="YES！删除数据成功！";
        echo $jsoncallback . "(" . json_encode($data, JSON_UNESCAPED_UNICODE) . ")";
        mysqli_close($con);//关闭数据库
    }else{
        $data['status']="NO";
        $data['message']="NO！删除数据失败！，请稍候刷新重试！";
        echo $jsoncallback . "(" . json_encode($data, JSON_UNESCAPED_UNICODE) . ")";
        mysqli_close($con);//关闭数据库
    }
}
?>